package com.pi2e.view.activity;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageSwitcher;
import android.widget.ImageView;
import android.widget.ViewSwitcher.ViewFactory;
import butterknife.Bind;

import com.pi2e.R;
import com.pi2e.view.base.BaseActivity;
import com.pi2e.view.common.FootView;
import com.pi2e.view.common.HeaderView;

public class TodayVipActivity extends BaseActivity implements OnClickListener ,ViewFactory{
	private ImageSwitcher imageSwitcher;
    private Button button1,button2;
    private int index = 0;//用于浏览图片的次序
    private List<Drawable> list = new ArrayList<Drawable>();
	View mfootView ;
    
    ImageView mImgPerson ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    	// TODO Auto-generated method stub
    	super.onCreate(savedInstanceState);
    	 imageSwitcher = (ImageSwitcher) this.findViewById(R.id.imageSwitcher1);
         button1 = (Button)this.findViewById(R.id.button1);
         button2 = (Button)this.findViewById(R.id.button2);
         button1.setOnClickListener(this);
         button2.setOnClickListener(this);
         mImgPerson.setOnClickListener(this);
         imageSwitcher.setFactory(this);
         imageSwitcher.setOnClickListener(this);
         //往list集合里装载图片信息
         list.add(getResources().getDrawable(R.drawable.test_today_vip_01));
         list.add(getResources().getDrawable(R.drawable.test_today_vip_01));
        /* list.add(getResources().getDrawable(R.drawable.item4));
         list.add(getResources().getDrawable(R.drawable.item5));
         list.add(getResources().getDrawable(R.drawable.item6));
         list.add(getResources().getDrawable(R.drawable.item7));
         list.add(getResources().getDrawable(R.drawable.item8));*/
         //初始化加载图片的信息
         if(list.size() > 0){
             imageSwitcher.setImageDrawable(list.get(0));
         }
    }
	@Override
	public HeaderView initHeaderView() {
		return null;
	}

	@Override
	public void setContentView() {
		setContentView(R.layout.activity_todayvip);
		mImgPerson = (ImageView) findViewById(R.id.img_person) ;
	}

	@Override
	public void initView() {
		mfootView = findViewById(R.id.footId) ;
		
	}

	@Override
	public void initFootView() {
		FootView footView = new FootView(TodayVipActivity.this, mfootView) ;
		footView.getBtn_ok().setText("返 回");
		footView.getBtn_ok().setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				finish();
			}
		});
	}
	
	 @Override
	    public void onClick(View v) {
	        switch (v.getId()) {
	        case R.id.button1:
	            index--;
	            if(index < 0){
	                index = list.size() - 1;
	            }
	            imageSwitcher.setImageDrawable(list.get(index));
	            break;
	        case R.id.button2:
	            index++;
	            if(index >= list.size()){
	                index = 0;
	            }
	            imageSwitcher.setImageDrawable(list.get(index));
	            break ;
	        case R.id.img_person:
	        	finish();
	            break ;
	        case R.id.imageSwitcher1:
	        	Intent it = new Intent(TodayVipActivity.this, ReceDetailActivity.class) ;
	        	startActivity(it); 
	        default:
	            break;
	        }
	        
	    }


	    @Override
	    public View makeView() {
	        // TODO Auto-generated method stub
	        return new ImageView(TodayVipActivity.this);
}
}
